<script setup>
import { ref } from 'vue';
import { POST } from '../../api';
import router from '../../router';
import { ElMessage } from 'element-plus';


let adminAccount = ref(''), adminPassword = ref('')

//登录入口
async function login() {
  let res = await POST('http://localhost:9999/Admin/login', {
    adminAccount: adminAccount.value,
    adminPassword: adminPassword.value
  })
  if (res.code == 200) {
    ElMessage.success("登录成功")
    console.log(res.data)
    sessionStorage.setItem("token", res.data)
    router.push({ path: '/manager' })
  }
}


</script>


<template>
  <div class="container">
    <div class="login-wrapper">
      <div class="header">人力管理系统</div>

      <div class="form-wrapper">
        <input type="text" name="username" placeholder="用户名" class="input-item" v-model="adminAccount">
        <input type="password" name="password" placeholder="密码" class="input-item" v-model="adminPassword">
        <el-button class="LoginBut" type="primary" @click="login()">登录</el-button>
      </div>

    </div>
  </div>

</template>



<style scoped>
.container {
  position: absolute;
  top: 0;
  left: 0;
  margin-left: 0px;
  height: 100%;
  width: 100%;
  background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);

}

.login-wrapper {
  background-color: #fff;
  width: 358px;
  height: 588px;
  border-radius: 15px;
  padding: 0 50px;
  position: relative;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

}

.header {
  font-size: 38px;
  font-weight: bold;
  text-align: center;
  line-height: 200px;
}

.input-item {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  border: 0;
  padding: 10px;
  border-bottom: 1px solid rgb(128, 125, 125);
  font-size: 15px;
  outline: none;
}

.input-item:placeholder {
  text-transform: uppercase;
}

.btn {
  text-align: center;
  padding: 10px;
  width: 100%;
  margin-top: 40px;
  background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
  color: #fff;
}

.msg {
  text-align: center;
  line-height: 88px;
}

a {
  text-decoration-line: none;
  color: #abc1ee;
}

.LoginBut {
  display: block;
  margin: 0 auto;
}
</style>
